<?php

class event{
public function index(){
$city_id = intval($GLOBALS['request']['city_id']);
if(empty($city_id)){
$root['info']='改城市还没有开通哦！';
}
$page = intval($GLOBALS['request']['page']);
$page=$page==0?1:$page;
$page_size = PAGE_SIZE;
$limit = (($page-1)*$page_size).','.$page_size;
$sql_count = 'SELECT COUNT(id)  FROM '.DB_PREFIX."event  WHERE city_id='{$city_id}'   ";
$count=$GLOBALS['db']->getOne($sql_count);
$event=  $GLOBALS['db']->getAll('SELECT id,name,icon,event_begin_time,event_end_time,address FROM '.DB_PREFIX."event  WHERE city_id='{$city_id}' ");
foreach($event as $ek=>$ev)
{
$event[$ek]['event_begin_time']=Date('Y-m-d',$ev['event_begin_time']);
$event[$ek]['event_end_time']=date('Y-m-d',$ev['event_end_time']);
$event[$ek]['image']=get_abs_img_root(get_spec_image($ev['icon'],400,240,1));
unset($event[$ek]['icon']);
}
$root=array();
$root['item']=$event;
$page_total = ceil($count/$page_size);
$root['page'] = array('page'=>$page,'page_total'=>$page_total);
output($root);
}
}

?>